home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / gauntlet.c < prev    next >
C/C++ Source or Header  |  2000-05-18  |  38KB  |  1,168 lines

  1. /***************************************************************************
  2.  
  3.     Atari Gauntlet hardware
  4.  
  5.     driver by Aaron Giles
  6.  
  7.     Games supported:
  8.         * Gauntlet (1985) [3 sets]
  9.         * Gauntlet 2-player Version (1985)
  10.         * Gauntlet II (1986)
  11.         * Vindicators Part II (1988)
  12.  
  13.     Known bugs:
  14.         * none at this time
  15.  
  16. ****************************************************************************
  17.  
  18.     Memory map
  19.  
  20. ****************************************************************************
  21.  
  22.     ========================================================================
  23.     MAIN CPU
  24.     ========================================================================
  25.     000000-037FFF   R     xxxxxxxx xxxxxxxx   Program ROM
  26.     038000-03FFFF   R     xxxxxxxx xxxxxxxx   Slapstic-protected ROM
  27.     040000-07FFFF   R     xxxxxxxx xxxxxxxx   Program ROM
  28.     800000-801FFF   R/W   xxxxxxxx xxxxxxxx   Program RAM
  29.     802000-802FFF   R/W   -------- xxxxxxxx   EEPROM
  30.     803000          R     -------- xxxxxxxx   Input port 1
  31.     803002          R     -------- xxxxxxxx   Input port 2
  32.     803004          R     -------- xxxxxxxx   Input port 3
  33.     803006          R     -------- xxxxxxxx   Input port 4
  34.     803008          R     -------- -xxxx---   Status port
  35.                     R     -------- -x------      (VBLANK)
  36.                     R     -------- --x-----      (Sound command buffer full)
  37.                     R     -------- ---x----      (Sound response buffer full)
  38.                     R     -------- ----x---      (Self test)
  39.     80300E          R     -------- xxxxxxxx   Sound response read
  40.     803100            W   -------- --------   Watchdog reset
  41.     80312E            W   -------- -------x   Sound CPU reset
  42.     803140            W   -------- --------   VBLANK IRQ acknowledge
  43.     803150            W   -------- --------   EEPROM enable
  44.     803170            W   -------- xxxxxxxx   Sound command write
  45.     900000-901FFF   R/W   xxxxxxxx xxxxxxxx   Playfield RAM (64x64 tiles)
  46.                     R/W   x------- --------      (Horizontal flip)
  47.                     R/W   -xxx---- --------      (Palette select)
  48.                     R/W   ----xxxx xxxxxxxx      (Tile index)
  49.     902000-903FFF   R/W   xxxxxxxx xxxxxxxx   Motion object RAM (1024 entries x 4 words)
  50.                     R/W   -xxxxxxx xxxxxxxx      (0: Tile index)
  51.                     R/W   xxxxxxxx x-------      (1024: X position)
  52.                     R/W   -------- ----xxxx      (1024: Palette select)
  53.                     R/W   xxxxxxxx x-------      (2048: Y position)
  54.                     R/W   -------- -x------      (2048: Horizontal flip)
  55.                     R/W   -------- --xxx---      (2048: Number of X tiles - 1)
  56.                     R/W   -------- -----xxx      (2048: Number of Y tiles - 1)
  57.                     R/W   ------xx xxxxxxxx      (3072: Link to next object)
  58.     904000-904FFF   R/W   xxxxxxxx xxxxxxxx   Spare video RAM
  59.     905000-905FFF   R/W   xxxxxxxx xxxxxxxx   Alphanumerics RAM (64x32 tiles)
  60.                     R/W   x------- --------      (Opaque/transparent)
  61.                     R/W   -xxxxx-- --------      (Palette select)
  62.                     R/W   ------xx xxxxxxxx      (Tile index)
  63.     905F6E          R/W   xxxxxxxx x-----xx   Playfield Y scroll/tile bank select
  64.                     R/W   xxxxxxxx x-------      (Playfield Y scroll)
  65.                     R/W   -------- ------xx      (Playfield tile bank select)
  66.     910000-9101FF   R/W   xxxxxxxx xxxxxxxx   Alphanumercs palette RAM (256 entries)
  67.                     R/W   xxxx---- --------      (Intensity)
  68.                     R/W   ----xxxx --------      (Red)
  69.                     R/W   -------- xxxx----      (Green)
  70.                     R/W   -------- ----xxxx      (Blue)
  71.     910200-9103FF   R/W   xxxxxxxx xxxxxxxx   Motion object palette RAM (256 entries)
  72.     910400-9105FF   R/W   xxxxxxxx xxxxxxxx   Playfield palette RAM (256 entries)
  73.     910600-9107FF   R/W   xxxxxxxx xxxxxxxx   Extra palette RAM (256 entries)
  74.     930000            W   xxxxxxxx x-------   Playfield X scroll
  75.     ========================================================================
  76.     Interrupts:
  77.         IRQ4 = VBLANK
  78.         IRQ6 = sound CPU communications
  79.     ========================================================================
  80.  
  81.  
  82.     ========================================================================
  83.     SOUND CPU
  84.     ========================================================================
  85.     0000-0FFF   R/W   xxxxxxxx   Program RAM
  86.     1000          W   xxxxxxxx   Sound response write
  87.     1010        R     xxxxxxxx   Sound command read
  88.     1020        R     ----xxxx   Coin inputs
  89.                 R     ----x---      (Coin 1)
  90.                 R     -----x--      (Coin 2)
  91.                 R     ------x-      (Coin 3)
  92.                 R     -------x      (Coin 4)
  93.     1020          W   xxxxxxxx   Mixer control
  94.                   W   xxx-----      (TMS5220 volume)
  95.                   W   ---xx---      (POKEY volume)
  96.                   W   -----xxx      (YM2151 volume)
  97.     1030        R     xxxx----   Sound status read
  98.                 R     x-------      (Sound command buffer full)
  99.                 R     -x------      (Sound response buffer full)
  100.                 R     --x-----      (TMS5220 ready)
  101.                 R     ---x----      (Self test)
  102.     1030          W   x-------   YM2151 reset
  103.     1031          W   x-------   TMS5220 data strobe
  104.     1032          W   x-------   TMS5220 reset
  105.     1033          W   x-------   TMS5220 frequency
  106.     1800-180F   R/W   xxxxxxxx   POKEY communications
  107.     1810-1811   R/W   xxxxxxxx   YM2151 communications
  108.     1820          W   xxxxxxxx   TMS5220 data latch
  109.     1830        R/W   --------   IRQ acknowledge
  110.     4000-FFFF   R     xxxxxxxx   Program ROM
  111.     ========================================================================
  112.     Interrupts:
  113.         IRQ = timed interrupt
  114.         NMI = latch on sound command
  115.     ========================================================================
  116.  
  117. ****************************************************************************/
  118.  
  119.  
  120.  
  121. #include "driver.h"
  122. #include "machine/atarigen.h"
  123. #include "vidhrdw/generic.h"
  124.  
  125.  
  126. extern UINT8 vindctr2_screen_refresh;
  127.  
  128. WRITE_HANDLER( gauntlet_playfieldram_w );
  129. WRITE_HANDLER( gauntlet_hscroll_w );
  130. WRITE_HANDLER( gauntlet_vscroll_w );
  131.  
  132. void gauntlet_scanline_update(int scanline);
  133.  
  134. int gauntlet_vh_start(void);
  135. void gauntlet_vh_stop(void);
  136. void gauntlet_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  137.  
  138.  
  139. static UINT8 *speed_check;
  140. static UINT32 last_speed_check;
  141.  
  142. static UINT8 speech_val;
  143. static UINT8 last_speech_write;
  144. static UINT8 speech_squeak;
  145.  
  146. static UINT16 last_sound_reset;
  147.  
  148.  
  149.  
  150. /*************************************
  151.  *
  152.  *    Initialization of globals.
  153.  *
  154.  *************************************/
  155.  
  156. static void update_interrupts(void)
  157. {
  158.     int newstate = 0;
  159.  
  160.     if (atarigen_video_int_state)
  161.         newstate |= 4;
  162.     if (atarigen_sound_int_state)
  163.         newstate |= 6;
  164.  
  165.     if (newstate)
  166.         cpu_set_irq_line(0, newstate, ASSERT_LINE);
  167.     else
  168.         cpu_set_irq_line(0, 7, CLEAR_LINE);
  169. }
  170.  
  171.  
  172. static void scanline_update(int scanline)
  173. {
  174.     gauntlet_scanline_update(scanline);
  175.  
  176.     /* sound IRQ is on 32V */
  177.     if (scanline % 32 == 0)
  178.     {
  179.         if (scanline & 32)
  180.             atarigen_6502_irq_gen();
  181.         else
  182.             atarigen_6502_irq_ack_r(0);
  183.     }
  184. }
  185.  
  186.  
  187. static void init_machine(void)
  188. {
  189.     last_speed_check = 0;
  190.     last_speech_write = 0x80;
  191.     last_sound_reset = 1;
  192.     speech_squeak = 0;
  193.  
  194.     atarigen_eeprom_reset();
  195.     atarigen_slapstic_reset();
  196.     atarigen_interrupt_reset(update_interrupts);
  197.     atarigen_scanline_timer_reset(scanline_update, 8);
  198.     atarigen_sound_io_reset(1);
  199. }
  200.  
  201.  
  202.  
  203. /*************************************
  204.  *
  205.  *    Controller read dispatch.
  206.  *
  207.  *************************************/
  208.  
  209. static int fake_inputs(int real_port, int fake_port)
  210. {
  211.     int result = readinputport(real_port);
  212.     int fake = readinputport(fake_port);
  213.  
  214.     if (fake & 0x01)            /* up */
  215.     {
  216.         if (fake & 0x04)        /* up and left */
  217.             result &= ~0x20;
  218.         else if (fake & 0x08)    /* up and right */
  219.             result &= ~0x10;
  220.         else                    /* up only */
  221.             result &= ~0x30;
  222.     }
  223.     else if (fake & 0x02)        /* down */
  224.     {
  225.         if (fake & 0x04)        /* down and left */
  226.             result &= ~0x80;
  227.         else if (fake & 0x08)    /* down and right */
  228.             result &= ~0x40;
  229.         else                    /* down only */
  230.             result &= ~0xc0;
  231.     }
  232.     else if (fake & 0x04)        /* left only */
  233.         result &= ~0x60;
  234.     else if (fake & 0x08)        /* right only */
  235.         result &= ~0x90;
  236.  
  237.     return result;
  238. }
  239.  
  240.  
  241. static READ_HANDLER( control_r )
  242. {
  243.     /* differentiate Gauntlet input from Vindicators 2 inputs via the refresh flag */
  244.     if (!vindctr2_screen_refresh)
  245.     {
  246.         /* Gauntlet case */
  247.         int p1 = input_port_6_r(offset);
  248.         switch (offset)
  249.         {
  250.             case 0:
  251.                 return readinputport(p1);
  252.             case 2:
  253.                 return readinputport((p1 != 1) ? 1 : 0);
  254.             case 4:
  255.                 return readinputport((p1 != 2) ? 2 : 0);
  256.             case 6:
  257.                 return readinputport((p1 != 3) ? 3 : 0);
  258.         }
  259.     }
  260.     else
  261.     {
  262.         /* Vindicators 2 case */
  263.         switch (offset)
  264.         {
  265.             case 0:
  266.                 return fake_inputs(0, 6);
  267.             case 2:
  268.                 return fake_inputs(1, 7);
  269.             case 4:
  270.             case 6:
  271.                 return readinputport(offset / 2);
  272.         }
  273.     }
  274.     return 0xffff;
  275. }
  276.  
  277.  
  278.  
  279. /*************************************
  280.  *
  281.  *    I/O read dispatch.
  282.  *
  283.  *************************************/
  284.  
  285. static READ_HANDLER( input_r )
  286. {
  287.     int temp;
  288.  
  289.     switch (offset)
  290.     {
  291.         case 0:
  292.             temp = input_port_4_r(offset);
  293.             if (atarigen_cpu_to_sound_ready) temp ^= 0x0020;
  294.             if (atarigen_sound_to_cpu_ready) temp ^= 0x0010;
  295.             return temp;
  296.  
  297.         case 6:
  298.             return atarigen_sound_r(0);
  299.     }
  300.     return 0xffff;
  301. }
  302.  
  303.  
  304. static READ_HANDLER( switch_6502_r )
  305. {
  306.     int temp = 0x30;
  307.  
  308.     if (atarigen_cpu_to_sound_ready) temp ^= 0x80;
  309.     if (atarigen_sound_to_cpu_ready) temp ^= 0x40;
  310.     if (tms5220_ready_r()) temp ^= 0x20;
  311.     if (!(input_port_4_r(offset) & 0x0008)) temp ^= 0x10;
  312.  
  313.     return temp;
  314. }
  315.  
  316.  
  317.  
  318. /*************************************
  319.  *
  320.  *    Controller write dispatch.
  321.  *
  322.  *************************************/
  323.  
  324. static WRITE_HANDLER( input_w )
  325. {
  326.     switch (offset)
  327.     {
  328.         case 0x0e:        /* sound CPU reset */
  329.         {
  330.             int newword = COMBINE_WORD(last_sound_reset, data);
  331.             int diff = newword ^ last_sound_reset;
  332.             last_sound_reset = newword;
  333.             if (diff & 1)
  334.             {
  335.                 cpu_set_reset_line(1, (newword & 1) ? CLEAR_LINE : ASSERT_LINE);
  336.                 atarigen_sound_reset();
  337.             }
  338.             break;
  339.         }
  340.     }
  341. }
  342.  
  343.  
  344.  
  345. /*************************************
  346.  *
  347.  *    Sound TMS5220 write.
  348.  *
  349.  *************************************/
  350.  
  351. static WRITE_HANDLER( tms5220_w )
  352. {
  353.     (void)offset;
  354.     speech_val = data;
  355. }
  356.  
  357.  
  358.  
  359. /*************************************
  360.  *
  361.  *    Sound control write.
  362.  *
  363.  *************************************/
  364.  
  365. static WRITE_HANDLER( sound_ctl_w )
  366. {
  367.     switch (offset & 7)
  368.     {
  369.         case 0:    /* music reset, bit D7, low reset */
  370.             break;
  371.  
  372.         case 1:    /* speech write, bit D7, active low */
  373.             if (((data ^ last_speech_write) & 0x80) && (data & 0x80))
  374.                 tms5220_data_w(0, speech_val);
  375.             last_speech_write = data;
  376.             break;
  377.  
  378.         case 2:    /* speech reset, bit D7, active low */
  379.             if (((data ^ last_speech_write) & 0x80) && (data & 0x80))
  380.                 tms5220_reset();
  381.             break;
  382.  
  383.         case 3:    /* speech squeak, bit D7 */
  384.             data = 5 | ((data >> 6) & 2);
  385.             tms5220_set_frequency(ATARI_CLOCK_14MHz/2 / (16 - data));
  386.             break;
  387.     }
  388. }
  389.  
  390.  
  391.  
  392. /*************************************
  393.  *
  394.  *    Sound mixer write.
  395.  *
  396.  *************************************/
  397.  
  398. static WRITE_HANDLER( mixer_w )
  399. {
  400.     (void)offset;
  401.     atarigen_set_ym2151_vol((data & 7) * 100 / 7);
  402.     atarigen_set_pokey_vol(((data >> 3) & 3) * 100 / 3);
  403.     atarigen_set_tms5220_vol(((data >> 5) & 7) * 100 / 7);
  404. }
  405.  
  406.  
  407.  
  408. /*************************************
  409.  *
  410.  *    Speed cheats
  411.  *
  412.  *************************************/
  413.  
  414. static READ_HANDLER( speedup_68010_r )
  415. {
  416.     int result = READ_WORD(&speed_check[offset]);
  417.     int time = cpu_gettotalcycles();
  418.     int delta = time - last_speed_check;
  419.  
  420.     last_speed_check = time;
  421.     if (delta <= 100 && result == 0 && delta >= 0)
  422.         cpu_spin();
  423.  
  424.     return result;
  425. }
  426.  
  427.  
  428. static WRITE_HANDLER( speedup_68010_w )
  429. {
  430.     last_speed_check -= 1000;
  431.     COMBINE_WORD_MEM(&speed_check[offset], data);
  432. }
  433.  
  434.  
  435.  
  436. /*************************************
  437.  *
  438.  *    Main CPU memory handlers
  439.  *
  440.  *************************************/
  441.  
  442. static struct MemoryReadAddress main_readmem[] =
  443. {
  444.     { 0x000000, 0x07ffff, MRA_ROM },
  445.     { 0x800000, 0x801fff, MRA_BANK1 },
  446.     { 0x802000, 0x802fff, atarigen_eeprom_r },
  447.     { 0x803000, 0x803007, control_r },
  448.     { 0x803008, 0x80300f, input_r },
  449.     { 0x900000, 0x901fff, MRA_BANK2 },
  450.     { 0x902000, 0x903fff, MRA_BANK3 },
  451.     { 0x904000, 0x904fff, MRA_BANK4 },
  452.     { 0x905000, 0x905eff, MRA_BANK5 },
  453.     { 0x905f00, 0x905fff, MRA_BANK6 },
  454.     { 0x910000, 0x9107ff, paletteram_word_r },
  455.     { 0x930000, 0x930003, MRA_BANK7 },
  456.     { -1 }  /* end of table */
  457. };
  458.  
  459.  
  460. static struct MemoryWriteAddress main_writemem[] =
  461. {
  462.     { 0x000000, 0x07ffff, MWA_ROM },
  463.     { 0x800000, 0x801fff, MWA_BANK1 },
  464.     { 0x802000, 0x802fff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
  465.     { 0x803100, 0x803103, watchdog_reset_w },
  466.     { 0x803120, 0x80312f, input_w },
  467.     { 0x803140, 0x803143, atarigen_video_int_ack_w },
  468.     { 0x803150, 0x803153, atarigen_eeprom_enable_w },
  469.     { 0x803170, 0x803173, atarigen_sound_w },
  470.     { 0x900000, 0x901fff, gauntlet_playfieldram_w, &atarigen_playfieldram, &atarigen_playfieldram_size },
  471.     { 0x902000, 0x903fff, MWA_BANK3, &atarigen_spriteram, &atarigen_spriteram_size },
  472.     { 0x904000, 0x904fff, MWA_BANK4 },
  473.     { 0x905000, 0x905eff, MWA_BANK5, &atarigen_alpharam, &atarigen_alpharam_size },
  474.     { 0x905f6e, 0x905f6f, gauntlet_vscroll_w, &atarigen_vscroll },
  475.     { 0x905f00, 0x905fff, MWA_BANK6 },
  476.     { 0x910000, 0x9107ff, paletteram_IIIIRRRRGGGGBBBB_word_w, &paletteram },
  477.     { 0x930000, 0x930001, gauntlet_hscroll_w, &atarigen_hscroll },
  478.     { -1 }  /* end of table */
  479. };
  480.  
  481.  
  482.  
  483. /*************************************
  484.  *
  485.  *    Sound CPU memory handlers
  486.  *
  487.  *************************************/
  488.  
  489. static struct MemoryReadAddress sound_readmem[] =
  490. {
  491.     { 0x0000, 0x0fff, MRA_RAM },
  492.     { 0x1010, 0x101f, atarigen_6502_sound_r },
  493.     { 0x1020, 0x102f, input_port_5_r },
  494.     { 0x1030, 0x103f, switch_6502_r },
  495.     { 0x1800, 0x180f, pokey1_r },
  496.     { 0x1811, 0x1811, YM2151_status_port_0_r },
  497.     { 0x1830, 0x183f, atarigen_6502_irq_ack_r },
  498.     { 0x4000, 0xffff, MRA_ROM },
  499.     { -1 }  /* end of table */
  500. };
  501.  
  502.  
  503. static struct MemoryWriteAddress sound_writemem[] =
  504. {
  505.     { 0x0000, 0x0fff, MWA_RAM },
  506.     { 0x1000, 0x100f, atarigen_6502_sound_w },
  507.     { 0x1020, 0x102f, mixer_w },
  508.     { 0x1030, 0x103f, sound_ctl_w },
  509.     { 0x1800, 0x180f, pokey1_w },
  510.     { 0x1810, 0x1810, YM2151_register_port_0_w },
  511.     { 0x1811, 0x1811, YM2151_data_port_0_w },
  512.     { 0x1820, 0x182f, tms5220_w },
  513.     { 0x1830, 0x183f, atarigen_6502_irq_ack_w },
  514.     { 0x4000, 0xffff, MWA_ROM },
  515.     { -1 }  /* end of table */
  516. };
  517.  
  518.  
  519.  
  520. /*************************************
  521.  *
  522.  *    Port definitions
  523.  *
  524.  *************************************/
  525.  
  526. INPUT_PORTS_START( gauntlet )
  527.     PORT_START    /* 803000 */
  528.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
  529.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  530.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  531.     PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED )
  532.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 | IPF_8WAY )
  533.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER1 | IPF_8WAY )
  534.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER1 | IPF_8WAY )
  535.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER1 | IPF_8WAY )
  536.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  537.  
  538.     PORT_START    /* 803002 */
  539.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START2 )
  540.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  541.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  542.     PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED )
  543.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 | IPF_8WAY )
  544.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER2 | IPF_8WAY )
  545.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER2 | IPF_8WAY )
  546.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER2 | IPF_8WAY )
  547.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  548.  
  549.     PORT_START    /* 803004 */
  550.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START3 )
  551.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
  552.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
  553.     PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED )
  554.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER3 | IPF_8WAY )
  555.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER3 | IPF_8WAY )
  556.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER3 | IPF_8WAY )
  557.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER3 | IPF_8WAY )
  558.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  559.  
  560.     PORT_START    /* 803006 */
  561.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START4 )
  562.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER4 )
  563.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER4 )
  564.     PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED )
  565.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER4 | IPF_8WAY )
  566.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER4 | IPF_8WAY )
  567.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER4 | IPF_8WAY )
  568.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER4 | IPF_8WAY )
  569.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  570.  
  571.     PORT_START    /* 803008 */
  572.     PORT_BIT( 0x0007, IP_ACTIVE_HIGH, IPT_UNUSED )
  573.     PORT_SERVICE( 0x0008, IP_ACTIVE_LOW )
  574.     PORT_BIT( 0x0030, IP_ACTIVE_HIGH, IPT_SPECIAL )
  575.     PORT_BIT( 0x0040, IP_ACTIVE_LOW,  IPT_VBLANK )
  576.     PORT_BIT( 0xff80, IP_ACTIVE_HIGH, IPT_UNUSED )
  577.  
  578.     PORT_START    /* 1020 (sound) */
  579.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN4 )
  580.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN3 )
  581.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
  582.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 )
  583.     PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
  584.  
  585.     PORT_START    /* Fake! */
  586.     PORT_DIPNAME( 0x0003, 0x0000, "Player 1 Plays" )
  587.     PORT_DIPSETTING(      0x0000, "Red/Warrior" )
  588.     PORT_DIPSETTING(      0x0001, "Blue/Valkyrie" )
  589.     PORT_DIPSETTING(      0x0002, "Yellow/Wizard" )
  590.     PORT_DIPSETTING(      0x0003, "Green/Elf" )
  591. INPUT_PORTS_END
  592.  
  593.  
  594. INPUT_PORTS_START( vindctr2 )
  595.     PORT_START    /* 803000 */
  596.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  597.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  598.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  599.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 )
  600.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP    | IPF_PLAYER1 | IPF_2WAY )
  601.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP   | IPF_PLAYER1 | IPF_2WAY )
  602.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN  | IPF_PLAYER1 | IPF_2WAY )
  603.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN | IPF_PLAYER1 | IPF_2WAY )
  604.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  605.  
  606.     PORT_START    /* 803002 */
  607.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  608.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  609.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  610.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
  611.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP    | IPF_PLAYER2 | IPF_2WAY )
  612.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP   | IPF_PLAYER2 | IPF_2WAY )
  613.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN  | IPF_PLAYER2 | IPF_2WAY )
  614.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN | IPF_PLAYER2 | IPF_2WAY )
  615.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  616.  
  617.     PORT_START    /* 803004 */
  618.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
  619.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2 )
  620.     PORT_BIT( 0xfffc, IP_ACTIVE_LOW, IPT_UNUSED )
  621.  
  622.     PORT_START    /* 803006 */
  623.     PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )
  624.  
  625.     PORT_START    /* 803008 */
  626.     PORT_BIT( 0x0007, IP_ACTIVE_HIGH, IPT_UNUSED )
  627.     PORT_SERVICE( 0x0008, IP_ACTIVE_LOW )
  628.     PORT_BIT( 0x0030, IP_ACTIVE_HIGH, IPT_SPECIAL )
  629.     PORT_BIT( 0x0040, IP_ACTIVE_LOW,  IPT_VBLANK )
  630.     PORT_BIT( 0xff80, IP_ACTIVE_HIGH, IPT_UNUSED )
  631.  
  632.     PORT_START    /* 1020 (sound) */
  633.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN4 )
  634.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN3 )
  635.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
  636.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 )
  637.     PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
  638.  
  639.     PORT_START    /* single joystick */
  640.     PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_CHEAT | IPF_PLAYER1 )
  641.     PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_CHEAT | IPF_PLAYER1 )
  642.     PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_CHEAT | IPF_PLAYER1 )
  643.     PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_CHEAT | IPF_PLAYER1 )
  644.  
  645.     PORT_START    /* single joystick */
  646.     PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_CHEAT | IPF_PLAYER2 )
  647.     PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_CHEAT | IPF_PLAYER2 )
  648.     PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_CHEAT | IPF_PLAYER2 )
  649.     PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_CHEAT | IPF_PLAYER2 )
  650. INPUT_PORTS_END
  651.  
  652.  
  653.  
  654. /*************************************
  655.  *
  656.  *    Graphics definitions
  657.  *
  658.  *************************************/
  659.  
  660. static struct GfxLayout anlayout =
  661. {
  662.     8,8,
  663.     RGN_FRAC(1,1),
  664.     2,
  665.     { 0, 4 },
  666.     { 0, 1, 2, 3, 8, 9, 10, 11 },
  667.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
  668.     8*16
  669. };
  670.  
  671.  
  672. static struct GfxLayout pfmolayout =
  673. {
  674.     8,8,
  675.     RGN_FRAC(1,4),
  676.     4,
  677.     { RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4), RGN_FRAC(0,4) },
  678.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  679.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  680.     8*8
  681. };
  682.  
  683.  
  684. static struct GfxDecodeInfo gfxdecodeinfo[] =
  685. {
  686.     { REGION_GFX2, 0, &pfmolayout,  256, 32 },
  687.     { REGION_GFX1, 0, &anlayout,      0, 64 },
  688.     { -1 } /* end of array */
  689. };
  690.  
  691.  
  692.  
  693. /*************************************
  694.  *
  695.  *    Sound definitions
  696.  *
  697.  *************************************/
  698.  
  699. static struct YM2151interface ym2151_interface =
  700. {
  701.     1,
  702.     ATARI_CLOCK_14MHz/4,
  703.     { YM3012_VOL(48,MIXER_PAN_LEFT,48,MIXER_PAN_RIGHT) },
  704.     { 0 }
  705. };
  706.  
  707.  
  708. static struct POKEYinterface pokey_interface =
  709. {
  710.     1,
  711.     ATARI_CLOCK_14MHz/8,
  712.     { 32 },
  713. };
  714.  
  715.  
  716. static struct TMS5220interface tms5220_interface =
  717. {
  718.     ATARI_CLOCK_14MHz/2/11,    /* potentially ATARI_CLOCK_14MHz/2/9 as well */
  719.     80,
  720.     0
  721. };
  722.  
  723.  
  724.  
  725. /*************************************
  726.  *
  727.  *    Machine driver
  728.  *
  729.  *************************************/
  730.  
  731. static struct MachineDriver machine_driver_gauntlet =
  732. {
  733.     /* basic machine hardware */
  734.     {
  735.         {
  736.             CPU_M68010,        /* verified */
  737.             ATARI_CLOCK_14MHz/2,
  738.             main_readmem,main_writemem,0,0,
  739.             atarigen_video_int_gen,1
  740.         },
  741.         {
  742.             CPU_M6502,
  743.             ATARI_CLOCK_14MHz/8,
  744.             sound_readmem,sound_writemem,0,0,
  745.             0,0
  746.         }
  747.     },
  748.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,
  749.     1,
  750.     init_machine,
  751.  
  752.     /* video hardware */
  753.     42*8, 30*8, { 0*8, 42*8-1, 0*8, 30*8-1 },
  754.     gfxdecodeinfo,
  755.     1024,1024,
  756.     0,
  757.  
  758.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK,
  759.     0,
  760.     gauntlet_vh_start,
  761.     gauntlet_vh_stop,
  762.     gauntlet_vh_screenrefresh,
  763.  
  764.     /* sound hardware */
  765.     SOUND_SUPPORTS_STEREO,0,0,0,
  766.     {
  767.         {
  768.             SOUND_YM2151,
  769.             &ym2151_interface
  770.         },
  771.         {
  772.             SOUND_POKEY,
  773.             &pokey_interface
  774.         },
  775.         {
  776.             SOUND_TMS5220,
  777.             &tms5220_interface
  778.         }
  779.     },
  780.  
  781.     atarigen_nvram_handler
  782. };
  783.  
  784.  
  785.  
  786. /*************************************
  787.  *
  788.  *    ROM definition(s)
  789.  *
  790.  *************************************/
  791.  
  792. ROM_START( gauntlet )
  793.     ROM_REGION( 0x80000, REGION_CPU1 )    /* 8*64k for 68000 code */
  794.     ROM_LOAD_EVEN( "gauntlt1.9a",  0x00000, 0x08000, 0x46fe8743 )
  795.     ROM_LOAD_ODD ( "gauntlt1.9b",  0x00000, 0x08000, 0x276e15c4 )
  796.     ROM_LOAD_EVEN( "gauntlt1.10a", 0x38000, 0x04000, 0x6d99ed51 )
  797.     ROM_LOAD_ODD ( "gauntlt1.10b", 0x38000, 0x04000, 0x545ead91 )
  798.     ROM_LOAD_EVEN( "gauntlt1.7a",  0x40000, 0x08000, 0x6fb8419c )
  799.     ROM_LOAD_ODD ( "gauntlt1.7b",  0x40000, 0x08000, 0x931bd2a0 )
  800.  
  801.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for 6502 code */
  802.     ROM_LOAD( "gauntlt1.16r", 0x4000, 0x4000, 0x6ee7f3cc )
  803.     ROM_LOAD( "gauntlt1.16s", 0x8000, 0x8000, 0xfa19861f )
  804.  
  805.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  806.     ROM_LOAD( "gauntlt1.6p",  0x00000, 0x04000, 0x6c276a1d )
  807.  
  808.     ROM_REGION( 0x40000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  809.     ROM_LOAD( "gauntlt1.1a",  0x00000, 0x08000, 0x91700f33 )
  810.     ROM_LOAD( "gauntlt1.1b",  0x08000, 0x08000, 0x869330be )
  811.  
  812.     ROM_LOAD( "gauntlt1.1l",  0x10000, 0x08000, 0xd497d0a8 )
  813.     ROM_LOAD( "gauntlt1.1mn", 0x18000, 0x08000, 0x29ef9882 )
  814.  
  815.     ROM_LOAD( "gauntlt1.2a",  0x20000, 0x08000, 0x9510b898 )
  816.     ROM_LOAD( "gauntlt1.2b",  0x28000, 0x08000, 0x11e0ac5b )
  817.  
  818.     ROM_LOAD( "gauntlt1.2l",  0x30000, 0x08000, 0x29a5db41 )
  819.     ROM_LOAD( "gauntlt1.2mn", 0x38000, 0x08000, 0x8bf3b263 )
  820. ROM_END
  821.  
  822.  
  823. ROM_START( gauntir1 )
  824.     ROM_REGION( 0x80000, REGION_CPU1 )    /* 8*64k for 68000 code */
  825.     ROM_LOAD_EVEN( "gaun1ir1.9a",  0x00000, 0x08000, 0xfd871f81 )
  826.     ROM_LOAD_ODD ( "gaun1ir1.9b",  0x00000, 0x08000, 0xbcb2fb1d )
  827.     ROM_LOAD_EVEN( "gaun1ir1.10a", 0x38000, 0x04000, 0x4642cd95 )
  828.     ROM_LOAD_ODD ( "gaun1ir1.10b", 0x38000, 0x04000, 0xc8df945e )
  829.     ROM_LOAD_EVEN( "gaun1ir1.7a",  0x40000, 0x08000, 0xc57377b3 )
  830.     ROM_LOAD_ODD ( "gaun1ir1.7b",  0x40000, 0x08000, 0x1cac2071 )
  831.  
  832.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for 6502 code */
  833.     ROM_LOAD( "gauntlt1.16r", 0x4000, 0x4000, 0x6ee7f3cc )
  834.     ROM_LOAD( "gauntlt1.16s", 0x8000, 0x8000, 0xfa19861f )
  835.  
  836.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  837.     ROM_LOAD( "gauntlt1.6p",  0x00000, 0x04000, 0x6c276a1d )
  838.  
  839.     ROM_REGION( 0x40000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  840.     ROM_LOAD( "gauntlt1.1a",  0x00000, 0x08000, 0x91700f33 )
  841.     ROM_LOAD( "gauntlt1.1b",  0x08000, 0x08000, 0x869330be )
  842.  
  843.     ROM_LOAD( "gauntlt1.1l",  0x10000, 0x08000, 0xd497d0a8 )
  844.     ROM_LOAD( "gauntlt1.1mn", 0x18000, 0x08000, 0x29ef9882 )
  845.  
  846.     ROM_LOAD( "gauntlt1.2a",  0x20000, 0x08000, 0x9510b898 )
  847.     ROM_LOAD( "gauntlt1.2b",  0x28000, 0x08000, 0x11e0ac5b )
  848.  
  849.     ROM_LOAD( "gauntlt1.2l",  0x30000, 0x08000, 0x29a5db41 )
  850.     ROM_LOAD( "gauntlt1.2mn", 0x38000, 0x08000, 0x8bf3b263 )
  851. ROM_END
  852.  
  853.  
  854. ROM_START( gauntir2 )
  855.     ROM_REGION( 0x80000, REGION_CPU1 )    /* 8*64k for 68000 code */
  856.     ROM_LOAD_EVEN( "gaun1ir1.9a",  0x00000, 0x08000, 0xfd871f81 )
  857.     ROM_LOAD_ODD ( "gaun1ir1.9b",  0x00000, 0x08000, 0xbcb2fb1d )
  858.     ROM_LOAD_EVEN( "gaun1ir1.10a", 0x38000, 0x04000, 0x4642cd95 )
  859.     ROM_LOAD_ODD ( "gaun1ir1.10b", 0x38000, 0x04000, 0xc8df945e )
  860.     ROM_LOAD_EVEN( "gaun1ir2.7a",  0x40000, 0x08000, 0x73e1ad79 )
  861.     ROM_LOAD_ODD ( "gaun1ir2.7b",  0x40000, 0x08000, 0xfd248cea )
  862.  
  863.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for 6502 code */
  864.     ROM_LOAD( "gauntlt1.16r", 0x4000, 0x4000, 0x6ee7f3cc )
  865.     ROM_LOAD( "gauntlt1.16s", 0x8000, 0x8000, 0xfa19861f )
  866.  
  867.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  868.     ROM_LOAD( "gauntlt1.6p",  0x00000, 0x04000, 0x6c276a1d )
  869.  
  870.     ROM_REGION( 0x40000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  871.     ROM_LOAD( "gauntlt1.1a",  0x00000, 0x08000, 0x91700f33 )
  872.     ROM_LOAD( "gauntlt1.1b",  0x08000, 0x08000, 0x869330be )
  873.  
  874.     ROM_LOAD( "gauntlt1.1l",  0x10000, 0x08000, 0xd497d0a8 )
  875.     ROM_LOAD( "gauntlt1.1mn", 0x18000, 0x08000, 0x29ef9882 )
  876.  
  877.     ROM_LOAD( "gauntlt1.2a",  0x20000, 0x08000, 0x9510b898 )
  878.     ROM_LOAD( "gauntlt1.2b",  0x28000, 0x08000, 0x11e0ac5b )
  879.  
  880.     ROM_LOAD( "gauntlt1.2l",  0x30000, 0x08000, 0x29a5db41 )
  881.     ROM_LOAD( "gauntlt1.2mn", 0x38000, 0x08000, 0x8bf3b263 )
  882. ROM_END
  883.  
  884.  
  885. ROM_START( gaunt2p )
  886.     ROM_REGION( 0x80000, REGION_CPU1 )    /* 8*64k for 68000 code */
  887.     ROM_LOAD_EVEN( "gaunt2p.9a",   0x00000, 0x08000, 0x8784133f )
  888.     ROM_LOAD_ODD ( "gaunt2p.9b",   0x00000, 0x08000, 0x2843bde3 )
  889.     ROM_LOAD_EVEN( "gauntlt1.10a", 0x38000, 0x04000, 0x6d99ed51 )
  890.     ROM_LOAD_ODD ( "gauntlt1.10b", 0x38000, 0x04000, 0x545ead91 )
  891.     ROM_LOAD_EVEN( "gaunt2p.7a",   0x40000, 0x08000, 0x5b4ee415 )
  892.     ROM_LOAD_ODD ( "gaunt2p.7b",   0x40000, 0x08000, 0x41f5c9e2 )
  893.  
  894.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for 6502 code */
  895.     ROM_LOAD( "gauntlt1.16r", 0x4000, 0x4000, 0x6ee7f3cc )
  896.     ROM_LOAD( "gauntlt1.16s", 0x8000, 0x8000, 0xfa19861f )
  897.  
  898.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  899.     ROM_LOAD( "gauntlt1.6p",  0x00000, 0x04000, 0x6c276a1d )
  900.  
  901.     ROM_REGION( 0x40000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  902.     ROM_LOAD( "gauntlt1.1a",  0x00000, 0x08000, 0x91700f33 )
  903.     ROM_LOAD( "gauntlt1.1b",  0x08000, 0x08000, 0x869330be )
  904.  
  905.     ROM_LOAD( "gauntlt1.1l",  0x10000, 0x08000, 0xd497d0a8 )
  906.     ROM_LOAD( "gauntlt1.1mn", 0x18000, 0x08000, 0x29ef9882 )
  907.  
  908.     ROM_LOAD( "gauntlt1.2a",  0x20000, 0x08000, 0x9510b898 )
  909.     ROM_LOAD( "gauntlt1.2b",  0x28000, 0x08000, 0x11e0ac5b )
  910.  
  911.     ROM_LOAD( "gauntlt1.2l",  0x30000, 0x08000, 0x29a5db41 )
  912.     ROM_LOAD( "gauntlt1.2mn", 0x38000, 0x08000, 0x8bf3b263 )
  913. ROM_END
  914.  
  915.  
  916. ROM_START( gaunt2 )
  917.     ROM_REGION( 0x80000, REGION_CPU1 )    /* 8*64k for 68000 code */
  918.     ROM_LOAD_EVEN( "gauntlt2.9a",  0x00000, 0x08000, 0x46fe8743 )
  919.     ROM_LOAD_ODD ( "gauntlt2.9b",  0x00000, 0x08000, 0x276e15c4 )
  920.     ROM_LOAD_EVEN( "gauntlt2.10a", 0x38000, 0x04000, 0x45dfda47 )
  921.     ROM_LOAD_ODD ( "gauntlt2.10b", 0x38000, 0x04000, 0x343c029c )
  922.     ROM_LOAD_EVEN( "gauntlt2.7a",  0x40000, 0x08000, 0x58a0a9a3 )
  923.     ROM_LOAD_ODD ( "gauntlt2.7b",  0x40000, 0x08000, 0x658f0da8 )
  924.     ROM_LOAD_EVEN( "gauntlt2.6a",  0x50000, 0x08000, 0xae301bba )
  925.     ROM_LOAD_ODD ( "gauntlt2.6b",  0x50000, 0x08000, 0xe94aaa8a )
  926.  
  927.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for 6502 code */
  928.     ROM_LOAD( "gauntlt2.16r", 0x4000, 0x4000, 0x5c731006 )
  929.     ROM_LOAD( "gauntlt2.16s", 0x8000, 0x8000, 0xdc3591e7 )
  930.  
  931.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  932.     ROM_LOAD( "gauntlt2.6p",  0x00000, 0x04000, 0xd101905d )
  933.  
  934.     ROM_REGION( 0x60000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  935.     ROM_LOAD( "gauntlt2.1a",  0x00000, 0x08000, 0x09df6e23 )
  936.     ROM_LOAD( "gauntlt2.1b",  0x08000, 0x08000, 0x869330be )
  937.     ROM_LOAD( "gauntlt2.1c",  0x10000, 0x04000, 0xe4c98f01 )
  938.     ROM_RELOAD(               0x14000, 0x04000 )
  939.  
  940.     ROM_LOAD( "gauntlt2.1l",  0x18000, 0x08000, 0x33cb476e )
  941.     ROM_LOAD( "gauntlt2.1mn", 0x20000, 0x08000, 0x29ef9882 )
  942.     ROM_LOAD( "gauntlt2.1p",  0x28000, 0x04000, 0xc4857879 )
  943.     ROM_RELOAD(               0x2c000, 0x04000 )
  944.  
  945.     ROM_LOAD( "gauntlt2.2a",  0x30000, 0x08000, 0xf71e2503 )
  946.     ROM_LOAD( "gauntlt2.2b",  0x38000, 0x08000, 0x11e0ac5b )
  947.     ROM_LOAD( "gauntlt2.2c",  0x40000, 0x04000, 0xd9c2c2d1 )
  948.     ROM_RELOAD(               0x44000, 0x04000 )
  949.  
  950.     ROM_LOAD( "gauntlt2.2l",  0x48000, 0x08000, 0x9e30b2e9 )
  951.     ROM_LOAD( "gauntlt2.2mn", 0x50000, 0x08000, 0x8bf3b263 )
  952.     ROM_LOAD( "gauntlt2.2p",  0x58000, 0x04000, 0xa32c732a )
  953.     ROM_RELOAD(               0x5c000, 0x04000 )
  954. ROM_END
  955.  
  956.  
  957. ROM_START( vindctr2 )
  958.     ROM_REGION( 0x80000, REGION_CPU1 )    /* 8*64k for 68000 code */
  959.     ROM_LOAD_EVEN( "1186", 0x00000, 0x08000, 0xaf138263 )
  960.     ROM_LOAD_ODD ( "1187", 0x00000, 0x08000, 0x44baff64 )
  961.     ROM_LOAD_EVEN( "1196", 0x38000, 0x04000, 0xc92bf6dd )
  962.     ROM_LOAD_ODD ( "1197", 0x38000, 0x04000, 0xd7ace347 )
  963.     ROM_LOAD_EVEN( "3188", 0x40000, 0x08000, 0x10f558d2 )
  964.     ROM_LOAD_ODD ( "3189", 0x40000, 0x08000, 0x302e24b6 )
  965.     ROM_LOAD_EVEN( "2190", 0x50000, 0x08000, 0xe7dc2b74 )
  966.     ROM_LOAD_ODD ( "2191", 0x50000, 0x08000, 0xed8ed86e )
  967.     ROM_LOAD_EVEN( "2192", 0x60000, 0x08000, 0xeec2c93d )
  968.     ROM_LOAD_ODD ( "2193", 0x60000, 0x08000, 0x3fbee9aa )
  969.     ROM_LOAD_EVEN( "1194", 0x70000, 0x08000, 0xe6bcf458 )
  970.     ROM_LOAD_ODD ( "1195", 0x70000, 0x08000, 0xb9bf245d )
  971.  
  972.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for 6502 code */
  973.     ROM_LOAD( "1160", 0x4000, 0x4000, 0xeef0a003 )
  974.     ROM_LOAD( "1161", 0x8000, 0x8000, 0x68c74337 )
  975.  
  976.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  977.     ROM_LOAD( "1198",  0x00000, 0x04000, 0xf99b631a )
  978.  
  979.     ROM_REGION( 0xc0000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  980.     ROM_LOAD( "1101", 0x00000, 0x08000, 0xdd3833ad )
  981.     ROM_LOAD( "1166", 0x08000, 0x08000, 0xe2db50a0 )
  982.     ROM_LOAD( "1170", 0x10000, 0x08000, 0xf050ab43 )
  983.     ROM_LOAD( "1174", 0x18000, 0x08000, 0xb6704bd1 )
  984.     ROM_LOAD( "1178", 0x20000, 0x08000, 0xd3006f05 )
  985.     ROM_LOAD( "1182", 0x28000, 0x08000, 0x9046e985 )
  986.  
  987.     ROM_LOAD( "1102", 0x30000, 0x08000, 0xd505b04a )
  988.     ROM_LOAD( "1167", 0x38000, 0x08000, 0x1869c76d )
  989.     ROM_LOAD( "1171", 0x40000, 0x08000, 0x1b229c2b )
  990.     ROM_LOAD( "1175", 0x48000, 0x08000, 0x73c41aca )
  991.     ROM_LOAD( "1179", 0x50000, 0x08000, 0x9b7cb0ef )
  992.     ROM_LOAD( "1183", 0x58000, 0x08000, 0x393bba42 )
  993.  
  994.     ROM_LOAD( "1103", 0x60000, 0x08000, 0x50e76162 )
  995.     ROM_LOAD( "1168", 0x68000, 0x08000, 0x35c78469 )
  996.     ROM_LOAD( "1172", 0x70000, 0x08000, 0x314ac268 )
  997.     ROM_LOAD( "1176", 0x78000, 0x08000, 0x061d79db )
  998.     ROM_LOAD( "1180", 0x80000, 0x08000, 0x89c1fe16 )
  999.     ROM_LOAD( "1184", 0x88000, 0x08000, 0x541209d3 )
  1000.  
  1001.     ROM_LOAD( "1104", 0x90000, 0x08000, 0x9484ba65 )
  1002.     ROM_LOAD( "1169", 0x98000, 0x08000, 0x132d3337 )
  1003.     ROM_LOAD( "1173", 0xa0000, 0x08000, 0x98de2426 )
  1004.     ROM_LOAD( "1177", 0xa8000, 0x08000, 0x9d0824f8 )
  1005.     ROM_LOAD( "1181", 0xb0000, 0x08000, 0x9e62b27c )
  1006.     ROM_LOAD( "1185", 0xb8000, 0x08000, 0x9d62f6b7 )
  1007. ROM_END
  1008.  
  1009.  
  1010.  
  1011. /*************************************
  1012.  *
  1013.  *    ROM decoding
  1014.  *
  1015.  *************************************/
  1016.  
  1017. static void rom_decode(void)
  1018. {
  1019.     UINT32 *p1, *p2, temp;
  1020.     UINT8 *data;
  1021.     int i;
  1022.  
  1023.     /* swap the top and bottom halves of the main CPU ROM images */
  1024.     p1 = (UINT32 *)&memory_region(REGION_CPU1)[0x000000];
  1025.     p2 = (UINT32 *)&memory_region(REGION_CPU1)[0x008000];
  1026.     for (i = 0; i < 0x8000 / 4; i++)
  1027.         temp = *p1, *p1++ = *p2, *p2++ = temp;
  1028.     p1 = (UINT32 *)&memory_region(REGION_CPU1)[0x040000];
  1029.     p2 = (UINT32 *)&memory_region(REGION_CPU1)[0x048000];
  1030.     for (i = 0; i < 0x8000 / 4; i++)
  1031.         temp = *p1, *p1++ = *p2, *p2++ = temp;
  1032.     p1 = (UINT32 *)&memory_region(REGION_CPU1)[0x050000];
  1033.     p2 = (UINT32 *)&memory_region(REGION_CPU1)[0x058000];
  1034.     for (i = 0; i < 0x8000 / 4; i++)
  1035.         temp = *p1, *p1++ = *p2, *p2++ = temp;
  1036.     p1 = (UINT32 *)&memory_region(REGION_CPU1)[0x060000];
  1037.     p2 = (UINT32 *)&memory_region(REGION_CPU1)[0x068000];
  1038.     for (i = 0; i < 0x8000 / 4; i++)
  1039.         temp = *p1, *p1++ = *p2, *p2++ = temp;
  1040.     p1 = (UINT32 *)&memory_region(REGION_CPU1)[0x070000];
  1041.     p2 = (UINT32 *)&memory_region(REGION_CPU1)[0x078000];
  1042.     for (i = 0; i < 0x8000 / 4; i++)
  1043.         temp = *p1, *p1++ = *p2, *p2++ = temp;
  1044.  
  1045.     /* highly strange -- the address bits on the chip at 2J (and only that
  1046.        chip) are scrambled -- this is verified on the schematics! */
  1047.     if (memory_region_length(REGION_GFX2) >= 0xc0000)
  1048.     {
  1049.         data = malloc(0x8000);
  1050.         if (data)
  1051.         {
  1052.             memcpy(data, &memory_region(REGION_GFX2)[0x88000], 0x8000);
  1053.             for (i = 0; i < 0x8000; i++)
  1054.             {
  1055.                 int srcoffs = (i & 0x4000) | ((i << 11) & 0x3800) | ((i >> 3) & 0x07ff);
  1056.                 memory_region(REGION_GFX2)[0x88000 + i] = data[srcoffs];
  1057.             }
  1058.             free(data);
  1059.         }
  1060.     }
  1061.  
  1062.     /* also invert the graphics bits on the playfield and motion objects */
  1063.     for (i = 0; i < memory_region_length(REGION_GFX2); i++)
  1064.         memory_region(REGION_GFX2)[i] ^= 0xff;
  1065. }
  1066.  
  1067.  
  1068.  
  1069. /*************************************
  1070.  *
  1071.  *    Driver initialization
  1072.  *
  1073.  *************************************/
  1074.  
  1075. static void init_gauntlet(void)
  1076. {
  1077.     atarigen_eeprom_default = NULL;
  1078.     atarigen_slapstic_init(0, 0x038000, 104);
  1079.  
  1080.     vindctr2_screen_refresh = 0;
  1081.  
  1082.     /* speed up the 6502 */
  1083.     atarigen_init_6502_speedup(1, 0x410f, 0x4127);
  1084.  
  1085.     /* speed up the 68010 */
  1086.     speed_check = install_mem_write_handler(0, 0x904002, 0x904003, speedup_68010_w);
  1087.     install_mem_read_handler(0, 0x904002, 0x904003, speedup_68010_r);
  1088.  
  1089.     /* display messages */
  1090.     atarigen_show_sound_message();
  1091.  
  1092.     rom_decode();
  1093. }
  1094.  
  1095.  
  1096. static void init_gaunt2p(void)
  1097. {
  1098.     atarigen_eeprom_default = NULL;
  1099.     atarigen_slapstic_init(0, 0x038000, 107);
  1100.  
  1101.     vindctr2_screen_refresh = 0;
  1102.  
  1103.     /* speed up the 6502 */
  1104.     atarigen_init_6502_speedup(1, 0x410f, 0x4127);
  1105.  
  1106.     /* speed up the 68010 */
  1107.     speed_check = install_mem_write_handler(0, 0x904002, 0x904003, speedup_68010_w);
  1108.     install_mem_read_handler(0, 0x904002, 0x904003, speedup_68010_r);
  1109.  
  1110.     /* display messages */
  1111.     atarigen_show_sound_message();
  1112.  
  1113.     rom_decode();
  1114. }
  1115.  
  1116.  
  1117. static void init_gauntlet2(void)
  1118. {
  1119.     atarigen_eeprom_default = NULL;
  1120.     atarigen_slapstic_init(0, 0x038000, 106);
  1121.  
  1122.     vindctr2_screen_refresh = 0;
  1123.  
  1124.     /* speed up the 6502 */
  1125.     atarigen_init_6502_speedup(1, 0x410f, 0x4127);
  1126.  
  1127.     /* speed up the 68010 */
  1128.     speed_check = install_mem_write_handler(0, 0x904002, 0x904003, speedup_68010_w);
  1129.     install_mem_read_handler(0, 0x904002, 0x904003, speedup_68010_r);
  1130.  
  1131.     /* display messages */
  1132.     atarigen_show_sound_message();
  1133.  
  1134.     rom_decode();
  1135. }
  1136.  
  1137.  
  1138. static void init_vindctr2(void)
  1139. {
  1140.     atarigen_eeprom_default = NULL;
  1141.     atarigen_slapstic_init(0, 0x038000, 118);
  1142.  
  1143.     vindctr2_screen_refresh = 1;
  1144.  
  1145.     /* speed up the 6502 */
  1146.     atarigen_init_6502_speedup(1, 0x40ff, 0x4117);
  1147.  
  1148.     /* display messages */
  1149.     atarigen_show_sound_message();
  1150.  
  1151.     rom_decode();
  1152. }
  1153.  
  1154.  
  1155.  
  1156. /*************************************
  1157.  *
  1158.  *    Game driver(s)
  1159.  *
  1160.  *************************************/
  1161.  
  1162. GAME( 1985, gauntlet, 0,        gauntlet, gauntlet, gauntlet,  ROT0, "Atari Games", "Gauntlet" )
  1163. GAME( 1985, gauntir1, gauntlet, gauntlet, gauntlet, gauntlet,  ROT0, "Atari Games", "Gauntlet (Intermediate Release 1)" )
  1164. GAME( 1985, gauntir2, gauntlet, gauntlet, gauntlet, gauntlet,  ROT0, "Atari Games", "Gauntlet (Intermediate Release 2)" )
  1165. GAME( 1985, gaunt2p,  gauntlet, gauntlet, gauntlet, gaunt2p,   ROT0, "Atari Games", "Gauntlet (2 Players)" )
  1166. GAME( 1986, gaunt2,   0,        gauntlet, gauntlet, gauntlet2, ROT0, "Atari Games", "Gauntlet II" )
  1167. GAME( 1988, vindctr2, 0,        gauntlet, vindctr2, vindctr2,  ROT0, "Atari Games", "Vindicators Part II" )
  1168.